package com.lzy.liujing.restaurant.dao;

import com.lzy.liujing.restaurant.entity.OrderDetail;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderDetailDao{
    @Delete("delete from r_order_detail where od_id =#{odId}")
    int delete(Integer id);

    @Select("select * from r_order_detail ")
    List<OrderDetail> findPage(OrderDetail query);
    @Update("update r_order_detail set  goods_id = #{goodsId}, count = #{count}," +
            " status = #{status}, description = #{description} where od_id = #{odId}")
    int update(OrderDetail brand);

    @Select("select * from r_order_detail")
    List<OrderDetail> selectAll();

    @Select("SELECT * FROM r_order_detail where od_id =#{odId}")
    OrderDetail getById(Integer id);

    @Insert("insert into r_order_detail (order_id, goods_id, count, status,category_id,createTime, description,cost,price ) values " +
            " (#{orderId},#{goodsId},#{count}, " +
            " #{status},#{categoryId},#{createTime},#{description} ,#{cost},#{price})")
    int Insert(OrderDetail orderDetail);

    @Delete("delete from r_order_detail where goods_id = #{goodsId}")
    int deleteById(Integer id);

    @Update({
            "<script>",
            "UPDATE r_order_detail",
            "SET status = #{status}",
            "WHERE od_id = #{odId}",
            "</script>"
    })
    int updateTotalPriceByOrderCode(Integer odId, String status);
}
